package com.puboot.common.util;

import com.puboot.module.admin.model.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.ui.Model;

/**
 * @author cai
 * <p>
 * create at 2021/5/10
 */
public class LoginUtil {

    public static void loginInfo(Model model) {
        boolean authenticated = SecurityUtils.getSubject().isAuthenticated();
        model.addAttribute("authenticated", authenticated);
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        if (user != null) {
            model.addAttribute("userLoginName", user.getUsername());
        }
    }

}
